import { createRouter, createWebHistory } from "vue-router";
import Login from "../views/Login.vue";
import page from "./page"
import shows from "@/redirect/indexs.vue"
const routes = [
  {
    path: "/",
    redirect:"login"
  },
  {
    path: "/login",
    name:"login",
    component:Login
  },
  
  {
    path: "/home",
    name: "home",
    meta: {
      title: "首页",
    },
    component: () =>import("../views/Home.vue"),
    children:[
      {       
          path: "mainpage",
          name:"mainpage",
          component: () =>import("@/views/Mainpage.vue"),   
      },
      // {       
      //   path: "commod",
      //   name:"commod",
      //   component: () =>impor@/views/Commodities/Commoditiesadd.vuevue"),
      //   meta: {
      //     title: "添加页面",
      //     keepAlive:true
      //   },
      // },
      {       
        path: "useras",
        name:"useras",
        component: () =>import("@/views/Useras.vue"), 
        meta: {
          title: "个人信息",
        },
      },
      {       
        path: "changcode",
        name:"changcode",
        component: () =>import("@/Subassembly/ChangCode.vue"), 
        meta: {
          title: "修改密码",
        },
      },
      ...page, 
    ],   
  },

  {
    path: "/redirect",
    name: "redirect",
    component: () =>
    import( "@/views/Home.vue"),
    children:[
      {
     path: "/redirect/:path(.*)",
     name:"redirect-child",
     component:shows,
     meta:{
      title:"首页"
    }
    },
   ] ,
  },
  {
    path: "/:path(.*)+",
    name: "404",
    component: ()=>import("../views/404.vue")
 
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
